package com.erlinyou.im.web.vo;

import com.erlinyou.im.web.controller.base.JsonUtil;

/**
 * 用于推送到客户端的消息
 * @author Administrator
 *
 */
public class PushMessage <T>{
	public enum PushMessageType{
		CHAT(1),//聊天消息
		SYS(2),//系统消息
		NOTICE(3),//通知消息
		OUTLINE(4),//下线消息
		voipcomment(6),//voip指令
		voidsignaling(7);//voip信令
		private int code;
		PushMessageType(int code){
			this.code = code;
		};
		public int getCode() {
			return code;
		}
	}
	public PushMessage(T message,PushMessageType type){
		this.message = message;
		this.type = type.getCode();
	}
	public PushMessage(PushMessageType type){
		this.type = type.getCode();
	}
	/**
	 * 消息
	 */
	private T message;
	/**
	 * 消息类型
	 * 1	聊天消息
	 * 2	系统消息
	 * 3	通知消息
	 */
	private int type;
	public T getMessage() {
		return message;
	}
	public PushMessage<T> setMessage(T message) {
		this.message = message;
		return this;
	}
	public int getType() {
		return type;
	}
	public PushMessage<T> setType(int type) {
		this.type = type;
		return this;
	}
	public  String buildJson(){
		return JsonUtil.ObjectToJson(this);
	}
	
}
